<?php /*a:3:{s:70:"D:\phpstudy_pro\WWW\oldi-erp\app\admin\view\stroages\inventorylog.html";i:1747733331;s:62:"D:\phpstudy_pro\WWW\oldi-erp\app\admin\view\public\header.html";i:1747733208;s:61:"D:\phpstudy_pro\WWW\oldi-erp\app\admin\view\public\style.html";i:1747733208;}*/ ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ERP</title>

    <link rel="stylesheet" href="/static/css/element-ui@2.15.14.css">
    <script src="/static/js/vue.js"></script>
    <script src="/static/js/element-ui@2.15.14.js"></script>
    <script src="/static/js/axios.js"></script>
    <script src="/static/js/qs.js"></script>
    <script src="/static/js/config.js"></script>
    <script src="/static/js/echart.js"></script>



        <style scoped>
            .el-select-dropdown {
               padding: 0;
            }
        
            /* 隐藏树形表格的下拉箭头 */
            .el-table .el-table__row .el-table__expand-icon {
               display: none;
            }

        </style>
        
<style>
    html,
    body,
    #app {
        padding: 0;
        margin: 0;
    }    
    #contenr{
        padding: 0;
        margin: 10px;
    }
</style>

<body>
    <div id="app"  v-cloak>
        <div id="contenr">
        <el-breadcrumb separator="/">
            <el-breadcrumb-item>首页</el-breadcrumb-item>
            <el-breadcrumb-item>库存管理</el-breadcrumb-item>
            <el-breadcrumb-item>库存日志</el-breadcrumb-item>
        </el-breadcrumb>
        <br>
        <el-card >
            <div style="display: flex;align-items: center;justify-content: flex-start;">      
                <el-form :inline="true" :model="searchForm" size="mini"  ref="refsearchForm">
                
                    <el-form-item label="库存变化类型">
                        <el-select v-model="searchForm.log_type" placeholder="请选择库存变化类型" filterable clearable>
                            <el-option v-for="(item,index) in log_type" :key="index" :label="item" :value="index">
                            </el-option>
                        </el-select> 
                    </el-form-item>
                    <el-form-item label="仓库">
                        <el-select v-model="searchForm.storage_id" placeholder="请选择仓库" filterable clearable>
                            <el-option v-for="item in storages" :key="item.id" :label="item.name" :value="item.id">
                            </el-option>
                        </el-select> 
                    </el-form-item>
                    <el-form-item label="库存变化状态">
                        <el-select v-model="searchForm.status" placeholder="请选择库存变化状态" filterable clearable>
                            <el-option v-for="(item,index) in status" :key="index" :label="item" :value="index">
                            </el-option>
                        </el-select> 
                    </el-form-item>
                    <el-form-item label="产品款号">
                        <el-input v-model="searchForm.localsku" placeholder="请输入产品款号" clearable filterable></el-input>
                    </el-form-item>     
                    
                    <el-form-item label="添加时间">
                        <el-date-picker v-model="searchForm.create_time"  type="daterange"   :picker-options="pickerOptions" range-separator="至" start-placeholder="开始日期"end-placeholder="结束日期"  align="right">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="完结时间">
                        <el-date-picker v-model="searchForm.operate_time"   type="daterange"   :picker-options="pickerOption" range-separator="至" start-placeholder="开始日期"end-placeholder="结束日期"  align="right">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item >
                        <el-button type="primary"  size="mini" plain @click="getSearch"  icon="el-icon-search" >查询</el-button>
                        <el-button type="success"  size="mini" plain @click="getExport"  icon="el-icon-s-promotion" >导出</el-button>
                    </el-form-item> 
                </el-form>              
            </div>

            <el-table  :data="tablelist" style="width: 100%;margin-bottom: 20px;" row-key="id"   border    :row-style="rowStyle"  class="hide-tree-arrow" default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
                <el-table-column  prop="name" label="仓库名称" sortable width="120"></el-table-column>
                <el-table-column  prop="nicakname" label="操作用户" ></el-table-column>
                <el-table-column  prop="log_type_name" label="库存变化类型"></el-table-column>
                <el-table-column  prop="notes" label="说明"  ></el-table-column>
                <el-table-column  prop="locasku" label="库存操作状态"  width="220">
                      <template v-slot="{row}">
                        <div v-if="row.localsku!=''">
                          {{row.localsku}}
                        </div>
                        <div v-if="row.localsku==''">
                            {{row.status}}                            
                       </div>
                      </template>
                </el-table-column>
                <el-table-column  prop="quantity" label="仓库变化(数量)"  width="100" ></el-table-column>   
                <el-table-column  prop="create_time" label="添加时间"  width="170"></el-table-column>            
                <el-table-column  prop="operate_time" label="完结时间" width="170" ></el-table-column>                
            </el-table>  
            <!-- page -->
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="searchForm.pagenum" :page-sizes="[20,50,100, 150, 300,500,1000,2000]"
                :page-size="searchForm.pagesize" layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination> 
        </el-card>  
    </div>

    <script>
        new Vue({
            el: '#app',
            data: function () {
                return {    
                    storages:<?php echo $storages; ?>,//仓库
                    status:<?php echo $status; ?>,//库存变化状态
                    log_type:<?php echo $log_type; ?>,//库存变化类型   
                    total:'',   //分页总页数      
                    tablelist:[] ,              
                    searchForm: {              
                        log_type: '',
                        localsku: '',
                        status:'',
                        operate_time:'',  
                        create_time:'',
                        storage_id:'',
                        pagenum: 1,
                        pagesize: 20,             
                    },  
                    pickerOptions: {
                        shortcuts: [{
                            text: '最近一周',
                            onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近一个月',
                            onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近三个月',
                            onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', [start, end]);
                            }
                        }]
                    },    
                    pickerOption: {
                        shortcuts: [{
                            text: '最近一周',
                            onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近一个月',
                            onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近三个月',
                            onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', [start, end]);
                            }
                        }]
                    },     
                    multipleSelection: [],
                            
                }
            },
            mounted(){        
                this.getSearch()
            },
            methods: {      
                // 动态设置行样式
                rowStyle({ row, rowIndex }) {
                    let style = {};       
                        if(!row.localsku){
                            style = { backgroundColor: '#c6e8ff', color: '#333' }; // 绿色f0f9eb
                        }   
                
                    return style;           
                },

                async getDatalist() {
                    const res = await axios.post('/admin/stroages/inventorylog', {params: this.searchForm})
                        if (res.status !== 1) {
                            return this.$message.error(res.info);
                        }
                    this.total = res.info.total
                    this.tablelist = res.info.list
                    console.log(this.tablelist)  

                },                    
                handleSizeChange(newSize) {
                    this.searchForm.pagesize = newSize
                    this.getDatalist()
                },
                handleCurrentChange(newPage) {
                    this.searchForm.pagenum = newPage
                    this.getDatalist()
                },
                handleSelectionChange(val) {
                    this.multipleSelection = val;
                },     
                getSearch() {
                    this.searchForm.pagenum = 1
                    this.getDatalist()
                },           
                //导出
                getExport() {     
                    window.location.href= '/admin/stroages/inventorylogExport?log_type='+this.searchForm.log_type+'&localsku='+this.searchForm.localsku+'&status='+this.searchForm.status+'&operate_time='+this.searchForm.operate_time+'&create_time='+this.searchForm.create_time+'&storage_id='+this.searchForm.storage_id;
                }
            }
        })
    </script>
</body>
</html>
